<template>
  <div class="box">
    <header>
      <p>宏烨找房</p>
      <div class="header_search">
        <span>北京</span>
        <span class="iconfont icon-down3"></span>
        <span class="wire"></span>
        <navigator url="/pages/search/search">
          <span>请在这里输入区域/商圈</span>
          <span class="iconfont icon-sousuo"></span>
        </navigator>
      </div>
    </header>
    <swiper
      indicator-dots="true"
      autoplay="true"
      interval="2000"
      duration="500"
      circular="true"
    >
      <block
        v-for="item in bannerList"
        :key="item.id"
      >
        <swiper-item>
          <!-- <view class="swiper-item {{item.src}}"></view> -->
          <img
            :src="'http://157.122.54.189:9060' + item.imgSrc"
            alt=""
          />
        </swiper-item>
      </block>
    </swiper>
    <div class="houseList">
      <div>
        <navigator
          :url="item.url"
          v-for="(item, index) in houseList"
          :key="index"
        >
          <img
            :src="'../../static/houseListimg/' + `${index + 1}` + '.png'"
            alt=""
          />
          <span>
            {{ item.text }}
          </span>
        </navigator>
      </div>
    </div>
    <!-- 楼市资讯 -->
    <div class="informatioin">
      <news />
    </div>
    <div class="hot">
      <p>
        <span>热门楼盘</span>
        <navigator>更多</navigator>
      </p>
      <navigator
        v-for="(item, index) in houses.list"
        :key="index"
      >
        <div>
          <img
            :src="
              'http://157.122.54.189:9060' +
              `${item.houseImg === '/newImg/img1' ? '' : item.houseImg}`
            "
            alt=""
          />
        </div>
        <div>
          <p>
            {{ item.title }}
          </p>
          <p>
            {{ item.desc }}
          </p>
          <p>{{ item.price }}万</p>
          <p>
            <span
              v-for="(ite, index) in item.tags"
              :key="index"
            >
              {{ ite }}
            </span>
          </p>
        </div>
      </navigator>
    </div>
    <div class="broker">
      <p>
        <span>经纪人</span>
        <navigator>更多</navigator>
      </p>
      <div>开发中....</div>

    </div>
  </div>
</template>

<script>
import news from "../../components/news.vue";
import "../../static/font_2197595_yt2keqic52s/iconfont.css";
import { getbanner, gethouseList } from "../../service/index";

export default {
  components: { news },
  data() {
    return {
      title: "Hello",
      bannerList: {},
      houses: [],
      houseList: [
        {
          text: "买房",
          url: "/pages/buyHouse/index"
        },
        {
          text: "租房",
          url: "/pages/buyHouse/index"
        },
        {
          text: "求租",
          url: "/pages/renting/index"
        },
        {
          text: "求购",
          url: "/pages/renting/index"
        },
        {
          text: "地图找房"
        },
        {
          text: "咨询",
          url: "/pages/news/index"
        },
        {
          text: "二手房",
          url: "/pages/secondHand/index"
        },
        {
          text: "经纪人",
          url: "/pages/agent/index"
        },
        {
          text: "团购看房",
          url:'/pages/groupbuying/index'
        },
        {
          text: "直播看房",
          url: "/pages/broadcast/index"
        }
      ]
    };
  },

  onLoad() {
    // wx.getUserInfo({
    //   success(res){
    //    console.log(res)
    //   }
    // })
    wx.getUserProfile({
      desc: "123",
      success(e) {
        console.log(e, "eeee");
      }
    });
  },
  onShow() {
    this.getbanner();
    this.gethouseList();
  },
  methods: {
    async getbanner() {
      let result = await getbanner();
      if (result.status === 200) {
        this.bannerList = result.body;
      }
    },
    async gethouseList() {
      let result = await gethouseList();
      if (result.status === 200) {
        this.houses = result.body;
      }
    }
  }
};
</script>
<style lang="scss" scoped>
.box {
  .informatioin {
    width: 95%;
    margin-bottom: 20rpx;
  }
}
header {
  padding: 68rpx 32rpx 34rpx 32rpx;
  background: #2391f9;
  position: sticky;
  top: 0;
  z-index: 9;
  > p {
    margin-bottom: 40rpx;
    font-size: 44rpx;
    color: #fff;
  }
  > div {
    height: 50rpx;
    display: flex;
    color: #fff;
    background: #8fc6f7;
    border-radius: 20rpx;
    padding: 10rpx 30rpx;
    > span:nth-child(1) {
      margin-right: 10rpx;
      font-size: 34rpx;
      width: 80rpx;
    }
    > span:nth-child(2) {
      font-size: 32rpx;
      position: relative;
      top: 10rpx;
      margin-right: 10rpx;
    }
    > navigator {
      font-size: 34rpx;
      margin-left: 40rpx;
      > span:nth-child(2) {
        margin-left: 80rpx;
      }
    }
  }
}
swiper {
  width: 100%;
  margin-bottom: 20rpx;
  img {
    width: 100%;
    height: 360rpx;
  }
  margin-bottom: 10rpx;
}
.houseList {
  padding: 0 32rpx 0 32rpx;
  margin-bottom: 20rpx;
  > div {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;

    > navigator {
      width: 20%;
      font-size: 30rpx;
      display: flex;
      flex-direction: column;
      align-items: center;
      padding-top: 20rpx;
      img {
        width: 100rpx;
        height: 100rpx;
      }
    }
  }
}
.hot {
  padding: 68rpx 32rpx 34rpx 32rpx;
  > p {
    display: flex;
    justify-content: space-between;
    span:nth-child(1) {
      font-size: 44rpx;
      font-weight: 900;
    }
    margin-bottom: 20rpx;
  }
  navigator {
    display: flex;
    margin-bottom: 20rpx;
    > div:nth-child(1) {
      margin-right: 40rpx;
    }
    > div:nth-child(2) {
      > p:nth-child(1) {
        font-weight: 900;
      }
      > p:nth-child(2) {
        font-size: 34rpx;
      }
      > p:nth-child(3) {
        font-size: 30rpx;
        color: coral;
        font-weight: 600;
      }
      > p:nth-child(4) {
        span {
          font-size: 30rpx;

          padding: 6rpx 30rpx;
          background: #eeeeee;
        }
      }
    }
    img {
      width: 300rpx;
      height: 200rpx;
    }
  }
}
.broker {
  padding: 68rpx 32rpx 34rpx 32rpx;

  > p {
    display: flex;
    justify-content: space-between;
    span:nth-child(1) {
      font-size: 44rpx;
      font-weight: 900;
    }
    margin-bottom: 20rpx;
  }
}
</style>
